package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo.DisplayNameComparator;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.appwoo.txtws.adapter.ListViewCreator;
import com.appwoo.txtws.adapter.Page;
import com.appwoo.txtws.adapter.SimpleListAdapter;
import com.appwoo.txtws.app.App;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.AppInfo;
import com.appwoo.txtws.wheel.widget.PageListView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class SetupFromLocalActivity extends AppActivity
{
  public static AppInfo appXiezai;
  private SimpleListAdapter<AppInfo> adapter;
  private List<AppInfo> appInfos;
  private ProgressDialog dialog = null;
  private Boolean isFoot = Boolean.valueOf(false);
  private LinearLayout llEmpty;
  private PageListView lvList;
  private Page<AppInfo> page;
  private ProgressBar pb;
  private PackageManager pm;

  private AppInfo getAppInfo(ApplicationInfo paramApplicationInfo)
  {
    AppInfo localAppInfo = new AppInfo();
    localAppInfo.setAppLabel((String)paramApplicationInfo.loadLabel(this.pm));
    localAppInfo.setAppIcon(paramApplicationInfo.loadIcon(this.pm));
    localAppInfo.setPkgName(paramApplicationInfo.packageName);
    return localAppInfo;
  }

  private void initView()
  {
    this.llEmpty = ((LinearLayout)findViewById(2131493266));
    this.pb = ((ProgressBar)findViewById(2131493215));
    this.page = new Page();
    this.page.setPageSize(200);
    this.appInfos = new ArrayList();
    this.lvList = ((PageListView)findViewById(2131492985));
    this.pm = getPackageManager();
    this.adapter = new SimpleListAdapter(this.page.getEntries(), new ListViewCreator()
    {
      public View createView(final AppInfo paramAnonymousAppInfo, View paramAnonymousView, int paramAnonymousInt)
      {
        if (paramAnonymousView == null)
          paramAnonymousView = App.getLayoutInflater().inflate(2130903121, null);
        ((TextView)paramAnonymousView.findViewById(2131493155)).setText(paramAnonymousAppInfo.getAppLabel());
        ((ImageView)paramAnonymousView.findViewById(2131493154)).setImageDrawable(paramAnonymousAppInfo.getAppIcon());
        Button localButton = (Button)paramAnonymousView.findViewById(2131493156);
        localButton.setText(SetupFromLocalActivity.this.getString(2131428210));
        final String str = paramAnonymousAppInfo.getPkgName();
        paramAnonymousAppInfo.getFilePath();
        localButton.setOnClickListener(new View.OnClickListener()
        {
          public void onClick(View paramAnonymous2View)
          {
            SetupFromLocalActivity.appXiezai = paramAnonymousAppInfo;
            Intent localIntent = new Intent();
            Uri localUri = Uri.parse("package:" + str);
            localIntent.setAction("android.intent.action.DELETE");
            localIntent.setData(localUri);
            SetupFromLocalActivity.this.startActivity(localIntent);
          }
        });
        return paramAnonymousView;
      }
    });
    this.lvList.setAdapter(this.adapter);
    this.lvList.hideFotterMoreView();
    addOperation(new DataTask().execute(new String[] { "" }));
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903146);
    initView();
  }

  protected void onResume()
  {
    super.onResume();
    try
    {
      if (this.pm.getLaunchIntentForPackage(appXiezai.getPkgName()) == null)
      {
        this.page.remove(appXiezai);
        this.adapter.notifyDataSetChanged();
        this.lvList.onLoadMoreComplete();
        this.lvList.hideFotterMoreView();
      }
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  class DataTask extends AsyncTask<String, Integer, String>
  {
    String param;

    DataTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      List localList = SetupFromLocalActivity.this.pm.getInstalledApplications(8192);
      Collections.sort(localList, new ApplicationInfo.DisplayNameComparator(SetupFromLocalActivity.this.pm));
      Iterator localIterator = localList.iterator();
      while (true)
      {
        if (!localIterator.hasNext());
        ApplicationInfo localApplicationInfo;
        do
        {
          return null;
          localApplicationInfo = (ApplicationInfo)localIterator.next();
        }
        while (isCancelled());
        if (((0x1 & localApplicationInfo.flags) <= 0) && (!"com.appwoo.txtws.activity".equals(localApplicationInfo.packageName)) && (!"com.txtw.daemon".equals(localApplicationInfo.packageName)))
          SetupFromLocalActivity.this.appInfos.add(SetupFromLocalActivity.this.getAppInfo(localApplicationInfo));
        else if (((0x80 & localApplicationInfo.flags) != 0) && (!"com.appwoo.txtws.activity".equals(localApplicationInfo.packageName)) && (!"com.txtw.daemon".equals(localApplicationInfo.packageName)))
          SetupFromLocalActivity.this.appInfos.add(SetupFromLocalActivity.this.getAppInfo(localApplicationInfo));
      }
    }

    protected void onPostExecute(String paramString)
    {
      super.onPostExecute(paramString);
      if ((SetupFromLocalActivity.this.appInfos != null) && (SetupFromLocalActivity.this.appInfos.size() > 0))
      {
        SetupFromLocalActivity.this.page.setEntries(SetupFromLocalActivity.this.appInfos);
        SetupFromLocalActivity.this.adapter.notifyDataSetChanged();
        SetupFromLocalActivity.this.lvList.onLoadMoreComplete();
        SetupFromLocalActivity.this.lvList.hideFotterMoreView();
        SetupFromLocalActivity.this.appInfos.clear();
      }
      while (true)
      {
        if (!SetupFromLocalActivity.this.isFoot.booleanValue())
        {
          SetupFromLocalActivity.this.llEmpty.setVisibility(8);
          SetupFromLocalActivity.this.lvList.setVisibility(0);
          SetupFromLocalActivity.this.isFoot = Boolean.valueOf(false);
        }
        return;
        SetupFromLocalActivity.this.lvList.hideFotterMoreView();
        SetupFromLocalActivity.this.alertMessage("没有更多数据");
      }
    }

    protected void onPreExecute()
    {
      super.onPreExecute();
      if (!SetupFromLocalActivity.this.isFoot.booleanValue())
      {
        SetupFromLocalActivity.this.llEmpty.setVisibility(0);
        SetupFromLocalActivity.this.lvList.setVisibility(8);
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.SetupFromLocalActivity
 * JD-Core Version:    0.6.2
 */